{
GskRenderNode *node;
graphene_rect_t real_bounds;
- graphene_point_t real_start_point;
- graphene_point_t real_end_point;
float scale_x, scale_y, dx, dy;
+ gboolean need_gradient = FALSE;
+ const GdkRGBA *first_color;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (start_point != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
- real_start_point.x = scale_x * start_point->x + dx;
- real_start_point.y = scale_y * start_point->y + dy;
- real_end_point.x = scale_x * end_point->x + dx;
- real_end_point.y = scale_y * end_point->y + dy;
- node = gsk_repeating_linear_gradient_node_new (&real_bounds,
- &real_start_point,
- &real_end_point,
- stops,
- n_stops);
+ first_color = &stops[0].color;
+ for (gsize i = 0; i < n_stops; i ++)
+ {
+ if (!gdk_rgba_equal (first_color, &stops[i].color))
+ {
+ need_gradient = TRUE;
+ break;
+ }
+ }
+
+ if (need_gradient)
+ {
+ graphene_point_t real_start_point, real_end_point;
+
+ real_start_point.x = scale_x * start_point->x + dx;
+ real_start_point.y = scale_y * start_point->y + dy;
+ real_end_point.x = scale_x * end_point->x + dx;
+ real_end_point.y = scale_y * end_point->y + dy;
+
+ node = gsk_repeating_linear_gradient_node_new (&real_bounds,
+ &real_start_point,
+ &real_end_point,
+ stops,
+ n_stops);
+ }
+ else
+ {
+ node = gsk_color_node_new (first_color, &real_bounds);
+ }
gtk_snapshot_append_node_internal (snapshot, node);
}
{
GskRenderNode *node;
graphene_rect_t real_bounds;
- graphene_point_t real_center;
float scale_x, scale_y, dx, dy;
+ gboolean need_gradient = FALSE;
+ const GdkRGBA *first_color;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (center != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
- real_center.x = scale_x * center->x + dx;
- real_center.y = scale_y * center->y + dy;
-
- node = gsk_radial_gradient_node_new (&real_bounds,
- &real_center,
- hradius * scale_x,
- vradius * scale_y,
- start,
- end,
- stops,
- n_stops);
+
+ first_color = &stops[0].color;
+ for (gsize i = 0; i < n_stops; i ++)
+ {
+ if (!gdk_rgba_equal (first_color, &stops[i].color))
+ {
+ need_gradient = TRUE;
+ break;
+ }
+ }
+
+ if (need_gradient)
+ {
+ graphene_point_t real_center;
+
+ real_center.x = scale_x * center->x + dx;
+ real_center.y = scale_y * center->y + dy;
+
+ node = gsk_radial_gradient_node_new (&real_bounds,
+ &real_center,
+ hradius * scale_x,
+ vradius * scale_y,
+ start,
+ end,
+ stops,
+ n_stops);
+ }
+ else
+ {
+ node = gsk_color_node_new (first_color, &real_bounds);
+ }
gtk_snapshot_append_node_internal (snapshot, node);
}
{
GskRenderNode *node;
graphene_rect_t real_bounds;
- graphene_point_t real_center;
float scale_x, scale_y, dx, dy;
+ gboolean need_gradient = FALSE;
+ const GdkRGBA *first_color;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (center != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
- real_center.x = scale_x * center->x + dx;
- real_center.y = scale_y * center->y + dy;
-
- node = gsk_repeating_radial_gradient_node_new (&real_bounds,
- &real_center,
- hradius * scale_x,
- vradius * scale_y,
- start,
- end,
- stops,
- n_stops);
+
+ first_color = &stops[0].color;
+ for (gsize i = 0; i < n_stops; i ++)
+ {
+ if (!gdk_rgba_equal (first_color, &stops[i].color))
+ {
+ need_gradient = TRUE;
+ break;
+ }
+ }
+
+ if (need_gradient)
+ {
+ graphene_point_t real_center;
+
+ real_center.x = scale_x * center->x + dx;
+ real_center.y = scale_y * center->y + dy;
+ node = gsk_repeating_radial_gradient_node_new (&real_bounds,
+ &real_center,
+ hradius * scale_x,
+ vradius * scale_y,
+ start,
+ end,
+ stops,
+ n_stops);
+ }
+ else
+ {
+ node = gsk_color_node_new (first_color, &real_bounds);
+ }
gtk_snapshot_append_node_internal (snapshot, node);
}